<template>
  <view class="container">
    <scroll-view scroll-y="true" style="width: 100%; height: 100vh">
      <!-- 列表 -->
      <view class="list">
        <view class="item" v-for="item in list" :key="item.id">
          <image :src="imgUrl + item.avatar" mode="aspectFill" style="width: 186rpx; height: 186rpx"></image>
          <view class="right">
            <view class="name">
              <view style="font-size: 30rpx; font-family: PingFang SC, PingFang SC; font-weight: bold; color: #222222">{{ item.username }}</view>
              <image :src="`../../static/icon/${item.gender == 1 ? 'nv' : 'nan'}.png`" mode="" style="width: 42rpx; height: 42rpx"></image>
              <view class="school" v-if="item.school != ''">{{ item.school }}</view>
            </view>
            <view class="subject">{{ item.grade_name + ' | ' + item.subject_name }}</view>
            <view class="long">
              <view style="font-size: 28rpx; font-family: PingFang SC, PingFang SC; font-weight: 500; color: #222222">{{ item.distance }}km</view>
              <view class="jiedan" @click="remove(item.id)">从黑名单移除</view>
            </view>
          </view>
        </view>
      </view>
    </scroll-view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      list: [], //
      page: 1,
      name: '',
      imgUrl: ''
    };
  },
  methods: {
    remove(id) {
      uni.$http
        .post('/black/add', {
          type: '2',
          black_people: id
        })
        .then((res) => {
          this.getlist();
          if (res.data.code == 1) {
            uni.showToast({
              title: res.data.msg,
              icon: 'none'
            });
          }
        });
    },
    // 获取列表
    async getlist() {
      const res = await uni.$http.post('/black/list', {
        type: '2',
        page: this.page,
        name: this.name
      });
      console.log('获取列表', res.data.data.list);
      this.list = res.data.data.list;
    }
  },
  onLoad() {
    this.imgUrl = this.imgurl;
    this.getlist();
  }
};
</script>

<style lang="scss" scoped>
.container {
  box-sizing: border-box;
  .list {
    box-sizing: border-box;
    margin: 30rpx;
    .item {
      box-sizing: border-box;
      display: flex;
      width: 690rpx;
      height: 230rpx;
      margin-bottom: 40rpx;
      padding: 20rpx;
      background-color: #fff;
      .right {
        flex: 1;
        margin-left: 20rpx;
        .name {
          display: flex;
          .school {
            font-size: 22rpx;
            font-family: PingFang SC, PingFang SC;
            font-weight: 500;
            width: 172rpx;
            height: 40rpx;
            background: #eaedfd;
            border-radius: 10rpx 10rpx 10rpx 10rpx;
            color: #3553e8;
            text-align: center;
            line-height: 40rpx;
            text-overflow: ellipsis;
            white-space: nowrap;
            overflow: hidden;
          }
        }
        .subject {
          font-size: 26rpx;
          font-family: PingFang SC, PingFang SC;
          font-weight: 500;
        }
        .long {
          display: flex;
          align-items: center;
          justify-content: space-between;
          margin-top: 18rpx;
          .jiedan {
            box-sizing: border-box;
            width: 220rpx;
            height: 60rpx;
            text-align: center;
            line-height: 60rpx;
            font-size: 28rpx;
            font-size: 28rpx;
            font-family: PingFang SC, PingFang SC;
            font-weight: 500;
            color: #333333;
            background: #e3e3e3;
            border-radius: 100rpx 100rpx 100rpx 100rpx;
          }
        }
      }
    }
  }
}
</style>
<style>
page {
  background-color: #f9f9f9;
}
</style>
